﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Gao.Poker.Domain;
using Gao.Poker.Services;
using Gao.Poker.ViewModel;

namespace Gao.Poker.App.ViewModel
{
    public class SendSmsViewModel : BaseViewModel
    {
        private List<Member> _members;
        private ObservableCollection<Member> _sendMembers;
        private List<SendSms> _sendSmses;
        public SendSms _sendSms;
        public String MemberName { get; set; }

        public SendSmsViewModel()
        {
            MemberName = String.Empty;
            SendSms = new SendSms();
            _sendMembers = new ObservableCollection<Member>();
        }


        public List<Member> Members
        {
            get
            {
                int[] ids = SendMembers.Select(a => a.ID).ToArray();
                _members = new MemberService().SearchMembers(ids, MemberName);
                return _members;
            }
            set { _members = value; }
        }

        public ObservableCollection<Member> SendMembers
        {
            get { return _sendMembers; }
            set { _sendMembers = value; }
        }

        public List<SendSms> SendSmses
        {
            get
            {
                _sendSmses = new SendSmsService().Search();
                return _sendSmses;
            }
        }

        public SendSms SendSms
        {
            get { return _sendSms; }
            set
            {
                _sendSms = value;
                OnPropertyChanged("SendSms");
            }
        }
    }
}
